{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "52a9d947",
   "metadata": {},
   "source": [
    "### 1. 进制"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1b9e92bb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 8 16\n"
     ]
    }
   ],
   "source": [
    "var1 = 0b10;  var2 = 0o10; var3 = 0x10\n",
    "print (var1, var2, var3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb68798a",
   "metadata": {},
   "source": [
    "### 2. 逻辑运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d16632f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "25"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# x and y 如果x为False，则返回False，否则返回y的计算值\n",
    "# x or y 如果x为True，则返回True，否则返回y的计算值\n",
    "10 and 20+5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "dc73c76e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 在内部 False的值就是0\n",
    "0 == False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3305aafc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 在内部 True的值就是1\n",
    "1 == True"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c55c7f43",
   "metadata": {},
   "source": [
    "### 3. 集合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3e7cd173",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 3, 5}\n"
     ]
    }
   ],
   "source": [
    "set1 = {1,3,5,5,3,1}\n",
    "print(set1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ffaef7d0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4, 5}\n",
      "{5}\n",
      "{1, 3}\n",
      "{1, 2, 3, 4}\n"
     ]
    }
   ],
   "source": [
    "set2 = {2,4,5}\n",
    "print(set1 | set2) # 集合的并集\n",
    "print(set1 & set2) # 集合的交集\n",
    "print(set1 - set2) # 集合的差集\n",
    "print(set1 ^ set2) # 集合的异或集。两个集合中不同时存在的元素集合 (set1|set2)-(set1&set2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3ec5c855",
   "metadata": {},
   "source": [
    "### 4. 字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "8b501519",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'giggle', 'height': 176}\n",
      "{'name': 'giggle', 'weight': 72}\n"
     ]
    }
   ],
   "source": [
    "# 通过元组序列构造字典\n",
    "dict2 = dict([('name','giggle'),('height',176)])\n",
    "print(dict2)\n",
    "dict2 = dict(name='giggle',weight=72)\n",
    "print(dict2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "04429bff",
   "metadata": {},
   "source": [
    "### 6. 'a'与97"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "dca2b002",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "97\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "print(ord('a'))\n",
    "print(chr(97))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "77260cc1",
   "metadata": {},
   "source": [
    "### 7. eval字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "b2f99f2b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "49"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = 8\n",
    "calc = \"5*x+9\"\n",
    "eval(calc)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bee749ac",
   "metadata": {},
   "source": [
    "### 8. 列表推导式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "afe5adbe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[3, 4, 5, 6, 8, 10, 9, 12, 15]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lst1 = [1, 2, 3]\n",
    "lst2 = [3, 4, 5]\n",
    "[x * y for x in lst1 for y in lst2]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36ccc239",
   "metadata": {},
   "source": [
    "### 9. 拆包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e89b103a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "99\n"
     ]
    }
   ],
   "source": [
    "def unpack(*files):\n",
    "    for i in files:\n",
    "        print(i)\n",
    "a = (2,3,4,5,99)\n",
    "unpack(*a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "055963f4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 ff\n",
      "2 tt\n"
     ]
    }
   ],
   "source": [
    "# 将复杂的两个可迭代的数据集，转换成简单的数据集\n",
    "for a,b in zip([1,2],['ff','tt']):\n",
    "    print(a,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0a83fc47",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "mining",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
